package com.zzy.face.service.impl;

import com.zzy.face.dao.AccountDao;
import com.zzy.face.model.Account;
import com.zzy.face.service.AccountService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author 朱泽玉
 * @Create 2022/1/29 10:11
 * @Description 账号功能详细
 * @Modified By:
 */
@Service
public class AccountServiceImpl implements AccountService {
    final AccountDao accountDao;

    public AccountServiceImpl(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    @Override
    public void save(Account account) {
        accountDao.save(account);
    }

    @Override
    public Account findByUid(Long uid) {
        return accountDao.getOne(uid);
    }

    @Override
    public Account findByMobile(String mobile) {
        return accountDao.findByMobile(mobile);
    }

    @Override
    public void del(Long uid) {
        Account account = findByUid(uid);
        accountDao.delete(account);
    }

    @Override
    public List<Account> findAccounts() {
        return accountDao.findAll();
    }
}
